<?php defined('InNcPHP') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3><?php echo $lang['type_index'];?></h3>
      <?php echo $output['top_link'];?>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="ticket_type_form" enctype="multipart/form-data" method="post">
    <input type="hidden" name="form_submit" value="ok" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation"><?php echo $lang['type_name'];?>:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="type_name" maxlength="20" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>

      <tr class="noborder">
          <td colspan="2" class="required"><label class="validation"><?php echo $lang['type_desc'];?>:</label></td>
      </tr>
      <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="type_desc" maxlength="20" class="txt"></td>
          <td class="vatop tips"></td>
      </tr>
      </tbody>
      <tfoot>
        <tr>
          <td colspan="2"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit'];?></span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>
//按钮先执行验证再提交表单
$(function(){
	$('#ticket_type_form').validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        rules : {
            type_name: {
                required: true,
                remote: {
                    url: 'index.php?act=ticket_type&op=check',
                    type: 'get'
                }
            },
            type_desc: 'required'
        },
        messages : {
            type_name : {
                required: '<?php echo $lang['type_name_null'];?>',
                remote: '<?php echo $lang['type_name_have'];?>'
            },
            type_desc: '<?php echo $lang['type_desc_null']; ?>'
        }
    });

	//提交
    $("#submitBtn").click(function(){
        $("#ticket_type_form").valid() && $("#ticket_type_form").submit();
    });
});
</script>